#ifndef __DRIVER_CTP816S_H__
#define __DRIVER_CTP816S_H__


#include "stdint.h"
#include "bsp_board.h"


// cpt816D 7bit adress 0x15,  8bit write adress 0x2A,read adress  0x2B
// cpt816S   8bit write adress 0x14,read adress  0x15
#define APP_SLAVE               0x15//normal slave addr
#define BOOT_SLAVE              0x6A//bootloader slave addr  0x6A<<1  == 0xD4

#define CTP_DEV_ID_ADDR         (0xA7)
#define CTP_VER_ADDR            (0xA9)
#define CTP_SLEEP_ADDR          (0xE5)

#define CTP_DEV_ID_816S         (0xB4)
#define CTP_DEV_ID_816T         (0xB5)
#define CTP_DEV_ID_816D         (0xB6) 
#define CTP_DEV_ID_INVALID      (0xFF)

#define FIRMWARE_VERSION_816S   0X03  // NEW IS 0X04

#define CTP_MODE_REG                   (0xFA)
#define CTP_SLEEP_REG                  (0xFE)
#define CTP_SLEEP_CMD                  (0x03)
#define CTP_REPORT_MODE_CMD            (0x60)
#define CTP_GESTRURE_MODE_CMD          (0x11)
#define CTP_REPORT_GESTRURE_MODE_CMD   (0x71)

#define TP_RES_SET() GPIO_SetBits(TP_RESET_PORT,   TP_RESET_PIN)
#define TP_RES_CLR() GPIO_ResetBits(TP_RESET_PORT, TP_RESET_PIN)

void BSP_TP_Drive_Init(void);
void driver_ctp816s_reset(void);
void driver_touch_ctp816s_init(void);
void driver_touch_ctp816s_read(uint8_t reg, uint8_t *p_data,uint8_t num);
void driver_touch_ctp816s_get_chip_id(uint8_t *p_chip_id);
void driver_touch_ctp816s_get_fw_version(uint8_t *p_fw_version);

bool ctp_hynitron_update(void);

void had_touch_interrupt_get_data(void);
void TP_enable_enter_sleep(uint8_t enable);
void Get_touch_region(uint16_t x,uint16_t y);



#endif

